package com.xujp.cloud.service.impl;

import com.xujp.cloud.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author Xjp
 * @version 1.0
 * @date 2021/5/3 下午 07:33
 */
@EnableBinding(Source.class)
public class MessageProviderImpl implements IMessageProvider {

    @Resource
    private MessageChannel output;


    @Override
    public String send() {

        String string = UUID.randomUUID().toString();
        this.output.send(MessageBuilder.withPayload(string).build());

        return string;
    }
}
